package com.hzqy.persistence.dao.activity;
import java.util.List;
import java.util.Map;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Repository;

import com.hzqy.persistence.dao.core.PersistenceDao;
import com.hzqy.web.vo.PmsUserVo;
import com.hzqy.web.vo.StatDataUserSextupleVo;
import com.hzqy.web.vo.UserBillVo;
import com.hzqy.web.vo.activity.AcIdouVo;

@Repository
public class ActivityIdouDao extends PersistenceDao<PmsUserVo, Integer>{
	protected final Logger LOG = LoggerFactory.getLogger(getClass());
	/**
	 * 插入Idou记录
	 * @param acNoteVo
	 * @return
	 */
	public int insertIdouRecord(AcIdouVo acIdou) {
		getSqlSession().insert(this.getNamespace() +"insertIdouRecord", acIdou);
		int id=acIdou.getF_ai_id();
		return id;
	}
	
	/**
	 * 插入补送Idou记录
	 * @param acNoteVo
	 * @return
	 */
	public int insertIdouRecordRepair(AcIdouVo acIdou) {
		getSqlSession().insert(this.getNamespace() +"insertIdouRecordRepair", acIdou);
		int id=acIdou.getF_ai_id();
		return id;
	}
	
	/**
	 * 修改idou记录手机号码
	 * @return
	 */
	public int updateIdouRecord(Map<String,Object> map){
		return getSqlSession().update(this.getNamespace() + "updateIdouRecord", map);
	}
	/**
	 * 修改idou记录手机号码
	 * @return
	 */
	public int updateIdouRecordRepair(Map<String,Object> map){
		return getSqlSession().update(this.getNamespace() + "updateIdouRecordRepair", map);
	}
	/**
	 * 查找是否已发送Idou
	 * @param ac_code
	 * @return
	 */
	public List<AcIdouVo> selectIdouList(Map map){
		return getSqlSession().selectList(this.getNamespace() + "selectIdouList",map);
	}
	
	/**
	 * 查询最近一次订购时间
	 * @param map
	 * @return
	 */
	public UserBillVo orderBillDate(Map<String,Object> map){
		return getSqlSession().selectOne(this.getNamespace() + "orderBillDate", map);
	}

	/**
	 * 查询是否有活动订购记录
	 * @param map
	 * @return
	 */
	public List<UserBillVo> orderBillRecord(Map<String,Object> map){
		return getSqlSession().selectList(this.getNamespace() + "orderBillRecord",map);
	}
	
	/**
	 * 查询所有要补送的idou记录
	 * @return
	 */
	public List<AcIdouVo> selectIdouRepair() {
		return getSqlSession().selectList(this.getNamespace() + "selectIdouRepair");
	}
	
	/**
	 * 查询送出idou总数
	 * @param code
	 * @return
	 */
	public int selectIdouTotal(String code) {
		return getSqlSession().selectOne(this.getNamespace() + "selectIdouTotal", code);
	}
	/**
	 * 查询送出idou总数活动期间内所有
	 * @param code
	 * @return
	 */
	public int selectIdouTotalAll(String code) {
		return getSqlSession().selectOne(this.getNamespace() + "selectIdouTotalAll", code);
	}
	/**
	 * 修改签到记录
	 * @return
	 */
	public int updateIdou(Map<String,Object> map){
		return getSqlSession().update(this.getNamespace() + "updateIdou", map);
	}
	/**
	 * 查询签到信息
	 * @param code
	 * @return
	 */
	public AcIdouVo selectIdouByIdActId(Map<String,Object> map) {
		return getSqlSession().selectOne(this.getNamespace() + "selectIdouByIdActId", map);
	}
	/**
	 * 查询签到总天数
	 * @param code
	 * @return
	 */
	public int selectIdouCount(Map<String,Object> map) {
		return getSqlSession().selectOne(this.getNamespace() + "selectIdouCount", map);
	}

	public StatDataUserSextupleVo selectSextuplEuserData(Map<String, Object> map) {
		return getSqlSession().selectOne(this.getNamespace() + "selectSextuplEuserData", map);
	}
}
